
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 10/17/2012 12:14:06
-- Generated from EDMX file: C:\Users\Tee\documents\visual studio 2010\Projects\VLUSM_Project\VLUSM_DataAccess\MainData.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [VLUSM];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_DonViLop]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Lop] DROP CONSTRAINT [FK_DonViLop];
GO
IF OBJECT_ID(N'[dbo].[FK_KhoaHocLop]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Lop] DROP CONSTRAINT [FK_KhoaHocLop];
GO
IF OBJECT_ID(N'[dbo].[FK_DonViPhienBanGiao]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhienBanGiao] DROP CONSTRAINT [FK_DonViPhienBanGiao];
GO
IF OBJECT_ID(N'[dbo].[FK_LoaiHoSoHoSoDaNop]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[HoSoDaNop] DROP CONSTRAINT [FK_LoaiHoSoHoSoDaNop];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienDanToc]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[SinhVien] DROP CONSTRAINT [FK_SinhVienDanToc];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienTonGiao]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[SinhVien] DROP CONSTRAINT [FK_SinhVienTonGiao];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienThamGiaOlympic]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ThamGiaOlympic] DROP CONSTRAINT [FK_SinhVienThamGiaOlympic];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienNghienCuuKhoaHoc]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[NghienCuuKhoaHoc] DROP CONSTRAINT [FK_SinhVienNghienCuuKhoaHoc];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienNhatKy]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[NhatKy] DROP CONSTRAINT [FK_SinhVienNhatKy];
GO
IF OBJECT_ID(N'[dbo].[FK_LopSinhVien]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[SinhVien] DROP CONSTRAINT [FK_LopSinhVien];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienHoSoDaNop]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[HoSoDaNop] DROP CONSTRAINT [FK_SinhVienHoSoDaNop];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienVanBangDuocNhan]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[VanBangDuocNhan] DROP CONSTRAINT [FK_SinhVienVanBangDuocNhan];
GO
IF OBJECT_ID(N'[dbo].[FK_LoaiVanBangVanBangDuocNhan]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[VanBangDuocNhan] DROP CONSTRAINT [FK_LoaiVanBangVanBangDuocNhan];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienHocBong]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[HocBong] DROP CONSTRAINT [FK_SinhVienHocBong];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienCauLacBoThamGia]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CauLacBoThamGia] DROP CONSTRAINT [FK_SinhVienCauLacBoThamGia];
GO
IF OBJECT_ID(N'[dbo].[FK_CauLacBoCauLacBoThamGia]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CauLacBoThamGia] DROP CONSTRAINT [FK_CauLacBoCauLacBoThamGia];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienThayDoiTrongQuaTrinhHoc]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ThayDoiTrongQuaTrinhHoc] DROP CONSTRAINT [FK_SinhVienThayDoiTrongQuaTrinhHoc];
GO
IF OBJECT_ID(N'[dbo].[FK_LoaiThayDoiThayDoiTrongQuaTrinhHoc]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ThayDoiTrongQuaTrinhHoc] DROP CONSTRAINT [FK_LoaiThayDoiThayDoiTrongQuaTrinhHoc];
GO
IF OBJECT_ID(N'[dbo].[FK_LoaiHoSoDonVi_LoaiHoSo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LoaiHoSoDonVi] DROP CONSTRAINT [FK_LoaiHoSoDonVi_LoaiHoSo];
GO
IF OBJECT_ID(N'[dbo].[FK_LoaiHoSoDonVi_DonVi]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LoaiHoSoDonVi] DROP CONSTRAINT [FK_LoaiHoSoDonVi_DonVi];
GO
IF OBJECT_ID(N'[dbo].[FK_QuyenDonVi_Quyen]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[QuyenDonVi] DROP CONSTRAINT [FK_QuyenDonVi_Quyen];
GO
IF OBJECT_ID(N'[dbo].[FK_QuyenDonVi_DonVi]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[QuyenDonVi] DROP CONSTRAINT [FK_QuyenDonVi_DonVi];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienKhenThuong]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[KhenThuongs] DROP CONSTRAINT [FK_SinhVienKhenThuong];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienKyLuat]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[KyLuats] DROP CONSTRAINT [FK_SinhVienKyLuat];
GO
IF OBJECT_ID(N'[dbo].[FK_HoatDongDoanTheHoatDongDoanTheThamGia]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[HoatDongDoanTheThamGias] DROP CONSTRAINT [FK_HoatDongDoanTheHoatDongDoanTheThamGia];
GO
IF OBJECT_ID(N'[dbo].[FK_HoatDongDoanTheThamGiaSinhVien]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[HoatDongDoanTheThamGias] DROP CONSTRAINT [FK_HoatDongDoanTheThamGiaSinhVien];
GO
IF OBJECT_ID(N'[dbo].[FK_SinhVienChinhSach]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[SinhVien] DROP CONSTRAINT [FK_SinhVienChinhSach];
GO
IF OBJECT_ID(N'[dbo].[FK_UserDonVi_User]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserDonVi] DROP CONSTRAINT [FK_UserDonVi_User];
GO
IF OBJECT_ID(N'[dbo].[FK_UserDonVi_DonVi]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserDonVi] DROP CONSTRAINT [FK_UserDonVi_DonVi];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Quyen]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Quyen];
GO
IF OBJECT_ID(N'[dbo].[DonVi]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DonVi];
GO
IF OBJECT_ID(N'[dbo].[User]', 'U') IS NOT NULL
    DROP TABLE [dbo].[User];
GO
IF OBJECT_ID(N'[dbo].[Lop]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Lop];
GO
IF OBJECT_ID(N'[dbo].[KhoaHoc]', 'U') IS NOT NULL
    DROP TABLE [dbo].[KhoaHoc];
GO
IF OBJECT_ID(N'[dbo].[PhienBanGiao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PhienBanGiao];
GO
IF OBJECT_ID(N'[dbo].[HoSoDaNop]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HoSoDaNop];
GO
IF OBJECT_ID(N'[dbo].[LoaiHoSo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LoaiHoSo];
GO
IF OBJECT_ID(N'[dbo].[TonGiao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TonGiao];
GO
IF OBJECT_ID(N'[dbo].[DanToc]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DanToc];
GO
IF OBJECT_ID(N'[dbo].[NhatKy]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NhatKy];
GO
IF OBJECT_ID(N'[dbo].[NghienCuuKhoaHoc]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NghienCuuKhoaHoc];
GO
IF OBJECT_ID(N'[dbo].[ThamGiaOlympic]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ThamGiaOlympic];
GO
IF OBJECT_ID(N'[dbo].[HoatDongDoanThe]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HoatDongDoanThe];
GO
IF OBJECT_ID(N'[dbo].[LoaiThayDoi]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LoaiThayDoi];
GO
IF OBJECT_ID(N'[dbo].[ThayDoiTrongQuaTrinhHoc]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ThayDoiTrongQuaTrinhHoc];
GO
IF OBJECT_ID(N'[dbo].[ChinhSach]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ChinhSach];
GO
IF OBJECT_ID(N'[dbo].[VanBangDuocNhan]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VanBangDuocNhan];
GO
IF OBJECT_ID(N'[dbo].[LoaiVanBang]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LoaiVanBang];
GO
IF OBJECT_ID(N'[dbo].[HocBong]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HocBong];
GO
IF OBJECT_ID(N'[dbo].[CauLacBoThamGia]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CauLacBoThamGia];
GO
IF OBJECT_ID(N'[dbo].[CauLacBo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CauLacBo];
GO
IF OBJECT_ID(N'[dbo].[SinhVien]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SinhVien];
GO
IF OBJECT_ID(N'[dbo].[KhenThuongs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[KhenThuongs];
GO
IF OBJECT_ID(N'[dbo].[KyLuats]', 'U') IS NOT NULL
    DROP TABLE [dbo].[KyLuats];
GO
IF OBJECT_ID(N'[dbo].[HoatDongDoanTheThamGias]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HoatDongDoanTheThamGias];
GO
IF OBJECT_ID(N'[dbo].[LoaiHoSoDonVi]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LoaiHoSoDonVi];
GO
IF OBJECT_ID(N'[dbo].[QuyenDonVi]', 'U') IS NOT NULL
    DROP TABLE [dbo].[QuyenDonVi];
GO
IF OBJECT_ID(N'[dbo].[UserDonVi]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserDonVi];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Quyen'
CREATE TABLE [dbo].[Quyen] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL,
    [QuyenConstraint] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DonVi'
CREATE TABLE [dbo].[DonVi] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [IsCapTruong] bit  NOT NULL,
    [MaDonVi] nvarchar(max)  NULL
);
GO

-- Creating table 'User'
CREATE TABLE [dbo].[User] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenTaiKhoan] nvarchar(max)  NOT NULL,
    [MatKhau] nvarchar(max)  NOT NULL,
    [TenNguoiDung] nvarchar(max)  NULL,
    [GioiTinh] bit  NULL,
    [DienThoai] int  NULL,
    [Email] nvarchar(max)  NULL,
    [IsLocked] bit  NOT NULL
);
GO

-- Creating table 'Lop'
CREATE TABLE [dbo].[Lop] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MaLop] nvarchar(max)  NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [DonViID] int  NOT NULL,
    [KhoaHocID] int  NOT NULL
);
GO

-- Creating table 'KhoaHoc'
CREATE TABLE [dbo].[KhoaHoc] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL,
    [NamNhapHoc] int  NULL,
    [MoTa] nvarchar(max)  NULL
);
GO

-- Creating table 'PhienBanGiao'
CREATE TABLE [dbo].[PhienBanGiao] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [NgayBanGiao] datetime  NULL,
    [NhanVienGiao] nvarchar(max)  NULL,
    [NhanVienNhan] nvarchar(max)  NULL,
    [SoLuong] int  NULL,
    [DonViID] int  NOT NULL,
    [TenGoi] nvarchar(max)  NULL,
    [MoTa] nvarchar(max)  NULL
);
GO

-- Creating table 'HoSoDaNop'
CREATE TABLE [dbo].[HoSoDaNop] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [NhanVienNhan] nvarchar(max)  NULL,
    [NgayNhan] datetime  NULL,
    [LoaiHoSoID] int  NOT NULL,
    [SinhVienID] int  NOT NULL
);
GO

-- Creating table 'LoaiHoSo'
CREATE TABLE [dbo].[LoaiHoSo] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [NhanVienTao] nvarchar(max)  NULL,
    [NgayTao] datetime  NULL,
    [NhanVienCapNhat] nvarchar(max)  NULL,
    [NgayCapNhat] datetime  NULL
);
GO

-- Creating table 'TonGiao'
CREATE TABLE [dbo].[TonGiao] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DanToc'
CREATE TABLE [dbo].[DanToc] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'NhatKy'
CREATE TABLE [dbo].[NhatKy] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [NoiDung] nvarchar(max)  NULL,
    [NgaySua] datetime  NOT NULL,
    [NhanVienSua] nvarchar(max)  NOT NULL,
    [SinhVienID] int  NOT NULL
);
GO

-- Creating table 'NghienCuuKhoaHoc'
CREATE TABLE [dbo].[NghienCuuKhoaHoc] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NULL,
    [MoTa] nvarchar(max)  NULL,
    [NgayThamGia] datetime  NULL,
    [Cap] nvarchar(max)  NULL,
    [ThanhTich] nvarchar(max)  NOT NULL,
    [SinhVienID] int  NOT NULL
);
GO

-- Creating table 'ThamGiaOlympic'
CREATE TABLE [dbo].[ThamGiaOlympic] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NULL,
    [MoTa] nvarchar(max)  NULL,
    [NgayThamGia] datetime  NULL,
    [Cap] nvarchar(max)  NULL,
    [ThanhTich] nvarchar(max)  NOT NULL,
    [SinhVienID] int  NOT NULL
);
GO

-- Creating table 'HoatDongDoanThe'
CREATE TABLE [dbo].[HoatDongDoanThe] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'LoaiThayDoi'
CREATE TABLE [dbo].[LoaiThayDoi] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'ThayDoiTrongQuaTrinhHoc'
CREATE TABLE [dbo].[ThayDoiTrongQuaTrinhHoc] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [SinhVienID] int  NOT NULL,
    [LoaiThayDoiID] int  NOT NULL
);
GO

-- Creating table 'ChinhSach'
CREATE TABLE [dbo].[ChinhSach] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenChinhSach] nvarchar(max)  NOT NULL,
    [LoaiChinhSach] nvarchar(max)  NULL
);
GO

-- Creating table 'VanBangDuocNhan'
CREATE TABLE [dbo].[VanBangDuocNhan] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [NgayNhan] nvarchar(max)  NULL,
    [MoTa] nvarchar(max)  NULL,
    [DonViQuyetDinh] nvarchar(max)  NULL,
    [LoaiVanBangID] int  NOT NULL,
    [SinhVienID] int  NOT NULL
);
GO

-- Creating table 'LoaiVanBang'
CREATE TABLE [dbo].[LoaiVanBang] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL,
    [NgayTao] datetime  NULL,
    [NhanVienTao] nvarchar(max)  NULL
);
GO

-- Creating table 'HocBong'
CREATE TABLE [dbo].[HocBong] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [NgayNhan] datetime  NULL,
    [MoTa] nvarchar(max)  NULL,
    [SinhVienID] int  NOT NULL,
    [TenGoi] nvarchar(max)  NULL
);
GO

-- Creating table 'CauLacBoThamGia'
CREATE TABLE [dbo].[CauLacBoThamGia] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [SinhVienID] int  NOT NULL,
    [CauLacBoID] int  NOT NULL
);
GO

-- Creating table 'CauLacBo'
CREATE TABLE [dbo].[CauLacBo] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TenGoi] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'SinhVien'
CREATE TABLE [dbo].[SinhVien] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MaSinhVien] nvarchar(max)  NOT NULL,
    [TenSinhVien] nvarchar(max)  NOT NULL,
    [HoSinhVien] nvarchar(max)  NOT NULL,
    [GioiTinh] bit  NULL,
    [NgaySinh] nvarchar(max)  NULL,
    [NoiSinh] nvarchar(max)  NULL,
    [EmailVanLang] nvarchar(max)  NULL,
    [EmailCaNhan] nvarchar(max)  NULL,
    [HinhAnh] varbinary(max)  NULL,
    [NgayTao] datetime  NULL,
    [NgayCapNhat] datetime  NULL,
    [NhanVienTao] nvarchar(max)  NULL,
    [NhanVienCapNhat] nvarchar(max)  NULL,
    [CMND_NgayCap] nvarchar(max)  NULL,
    [CMND_NoiCap] nvarchar(max)  NULL,
    [CMND_SoCMND] nvarchar(max)  NULL,
    [KetQuaTuyenSinh_DoiTuongTuyenSinh] nvarchar(max)  NULL,
    [KetQuaTuyenSinh_KhuVucTuyenSinh] nvarchar(max)  NULL,
    [KetQuaTuyenSinh_KhoiThi] nvarchar(max)  NULL,
    [KetQuaTuyenSinh_Mon1] float  NULL,
    [KetQuaTuyenSinh_Mon2] float  NULL,
    [KetQuaTuyenSinh_Mon3] float  NULL,
    [KetQuaTuyenSinh_SoBaoDanh] nvarchar(max)  NULL,
    [KetQuaTuyenSinh_TruongDangKy] nvarchar(max)  NULL,
    [LienLac_DiaChiLienLac_SoDienThoai] nvarchar(max)  NULL,
    [LienLac_DiaChiLienLac_DienThoaiCaNhan] nvarchar(max)  NULL,
    [LienLac_DiaChiLienLac_DiaChi] nvarchar(max)  NULL,
    [LienLac_DiaChiThuongTru_PhuongXaThiTran] nvarchar(max)  NULL,
    [LienLac_DiaChiThuongTru_QuanHuyenID] int  NULL,
    [LienLac_DiaChiThuongTru_TinhThanhID] int  NULL,
    [LienLac_DiaChiThuongTru_SoDienThoai] nvarchar(max)  NULL,
    [LienLac_DiaChiThuongTru_SoNha] nvarchar(max)  NULL,
    [LienLac_DiaChiTamTru_PhuongXaThiTran] nvarchar(max)  NULL,
    [LienLac_DiaChiTamTru_QuanHuyenID] int  NULL,
    [LienLac_DiaChiTamTru_TinhThanhID] int  NULL,
    [LienLac_DiaChiTamTru_SoDienThoai] nvarchar(max)  NULL,
    [LienLac_DiaChiTamTru_SoNha] nvarchar(max)  NULL,
    [QuanHeGiaDinh_SoLuongAnhChiEm] int  NULL,
    [QuanHeGiaDinh_NguoiCha_DanTocID] int  NULL,
    [QuanHeGiaDinh_NguoiCha_DienThoai] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiCha_Email] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiCha_HoKhauThuongTru] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiCha_HoTen] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiCha_NgheNghiep] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiCha_NamSinh] int  NULL,
    [QuanHeGiaDinh_NguoiCha_NoiLamViec] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiCha_QuocTich] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiCha_TonGiaoID] int  NULL,
    [QuanHeGiaDinh_NguoiMe_DanTocID] int  NULL,
    [QuanHeGiaDinh_NguoiMe_DienThoai] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiMe_Email] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiMe_HoKhauThuongTru] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiMe_HoTen] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiMe_NgheNghiep] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiMe_NamSinh] int  NULL,
    [QuanHeGiaDinh_NguoiMe_NoiLamViec] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiMe_QuocTich] nvarchar(max)  NULL,
    [QuanHeGiaDinh_NguoiMe_TonGiaoID] int  NULL,
    [QuaTrinhHocPhoThong_GhiChu] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_KhenThuong] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_KyLuat] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemToan] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemLy] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemHoa] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemVan] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemSu] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemSinh] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemDiaLy] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemNgoaiNgu] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_DiemTrungBinh] float  NULL,
    [QuaTrinhHocPhoThong_Lop10_XepLoaiHocLuc] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemToan] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemLy] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemHoa] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemVan] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemSu] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemSinh] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemDiaLy] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemNgoaiNgu] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_DiemTrungBinh] float  NULL,
    [QuaTrinhHocPhoThong_Lop11_XepLoaiHocLuc] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemToan] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemLy] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemHoa] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemVan] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemSu] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemSinh] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemDiaLy] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemNgoaiNgu] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_DiemTrungBinh] float  NULL,
    [QuaTrinhHocPhoThong_Lop12_XepLoaiHocLuc] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_TotNghiepPhoThong_NamTotNghiep] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_TotNghiepPhoThong_NgayCapBang] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_TotNghiepPhoThong_SoHieuBang] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_TotNghiepPhoThong_NoiCap] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_TotNghiepPhoThong_SoVaoSo] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_TotNghiepPhoThong_TotNghiepTruong] nvarchar(max)  NULL,
    [QuaTrinhHocPhoThong_TotNghiepPhoThong_XepLoaiTotNghiep] nvarchar(max)  NULL,
    [SinhHoatDang_NoiVaoDang] nvarchar(max)  NULL,
    [SinhHoatDang_NgayVaoDangChinhThuc] nvarchar(max)  NULL,
    [SinhHoatDang_NgayVaoDangDuBi] nvarchar(max)  NULL,
    [SinhHoatDoan_ChucVuDoanCaoNhat] nvarchar(max)  NULL,
    [SinhHoatDoan_ChucVuDoanVanLang] nvarchar(max)  NULL,
    [SinhHoatDoan_NangKhieu] nvarchar(max)  NULL,
    [SinhHoatDoan_NguyenVong] nvarchar(max)  NULL,
    [SinhHoatDoan_NgayVaoDoan] nvarchar(max)  NULL,
    [SinhHoatDoan_NoiVaoDoan] nvarchar(max)  NULL,
    [ThongTinKhac_DuSucKhoe] bit  NULL,
    [ThongTinKhac_GhiChu] nvarchar(max)  NULL,
    [ThongTinKhac_GhiChuSucKhoe] nvarchar(max)  NULL,
    [ThongTinKhac_SoPhongKTX] nvarchar(max)  NULL,
    [ThongTinKhac_TrangThaiHocTap] nvarchar(max)  NULL,
    [DanTocID] int  NULL,
    [TonGiaoID] int  NULL,
    [LopID] int  NULL,
    [ChinhSachID] int  NULL,
    [TotNghiepDaiHoc_SoHieuBang] nvarchar(max)  NULL,
    [TotNghiepDaiHoc_NgayCapBang] nvarchar(max)  NULL,
    [TotNghiepDaiHoc_NoiCap] nvarchar(max)  NULL,
    [TotNghiepDaiHoc_SoVaoSo] nvarchar(max)  NULL,
    [TotNghiepDaiHoc_GhiChu] nvarchar(max)  NULL
);
GO

-- Creating table 'KhenThuongs'
CREATE TABLE [dbo].[KhenThuongs] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [SinhVienID] int  NOT NULL
);
GO

-- Creating table 'KyLuats'
CREATE TABLE [dbo].[KyLuats] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [SinhVienID] int  NOT NULL
);
GO

-- Creating table 'HoatDongDoanTheThamGias'
CREATE TABLE [dbo].[HoatDongDoanTheThamGias] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MoTa] nvarchar(max)  NULL,
    [SinhVienID] int  NOT NULL,
    [HoatDongDoanTheID] int  NOT NULL,
    [SinhVien_ID] int  NOT NULL
);
GO

-- Creating table 'LoaiHoSoDonVi'
CREATE TABLE [dbo].[LoaiHoSoDonVi] (
    [LoaiHoSoes_ID] int  NOT NULL,
    [DonVis_ID] int  NOT NULL
);
GO

-- Creating table 'QuyenDonVi'
CREATE TABLE [dbo].[QuyenDonVi] (
    [Quyens_ID] int  NOT NULL,
    [DonVis_ID] int  NOT NULL
);
GO

-- Creating table 'UserDonVi'
CREATE TABLE [dbo].[UserDonVi] (
    [Users_ID] int  NOT NULL,
    [DonVis_ID] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'Quyen'
ALTER TABLE [dbo].[Quyen]
ADD CONSTRAINT [PK_Quyen]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'DonVi'
ALTER TABLE [dbo].[DonVi]
ADD CONSTRAINT [PK_DonVi]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'User'
ALTER TABLE [dbo].[User]
ADD CONSTRAINT [PK_User]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Lop'
ALTER TABLE [dbo].[Lop]
ADD CONSTRAINT [PK_Lop]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'KhoaHoc'
ALTER TABLE [dbo].[KhoaHoc]
ADD CONSTRAINT [PK_KhoaHoc]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'PhienBanGiao'
ALTER TABLE [dbo].[PhienBanGiao]
ADD CONSTRAINT [PK_PhienBanGiao]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'HoSoDaNop'
ALTER TABLE [dbo].[HoSoDaNop]
ADD CONSTRAINT [PK_HoSoDaNop]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'LoaiHoSo'
ALTER TABLE [dbo].[LoaiHoSo]
ADD CONSTRAINT [PK_LoaiHoSo]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'TonGiao'
ALTER TABLE [dbo].[TonGiao]
ADD CONSTRAINT [PK_TonGiao]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'DanToc'
ALTER TABLE [dbo].[DanToc]
ADD CONSTRAINT [PK_DanToc]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'NhatKy'
ALTER TABLE [dbo].[NhatKy]
ADD CONSTRAINT [PK_NhatKy]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'NghienCuuKhoaHoc'
ALTER TABLE [dbo].[NghienCuuKhoaHoc]
ADD CONSTRAINT [PK_NghienCuuKhoaHoc]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'ThamGiaOlympic'
ALTER TABLE [dbo].[ThamGiaOlympic]
ADD CONSTRAINT [PK_ThamGiaOlympic]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'HoatDongDoanThe'
ALTER TABLE [dbo].[HoatDongDoanThe]
ADD CONSTRAINT [PK_HoatDongDoanThe]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'LoaiThayDoi'
ALTER TABLE [dbo].[LoaiThayDoi]
ADD CONSTRAINT [PK_LoaiThayDoi]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'ThayDoiTrongQuaTrinhHoc'
ALTER TABLE [dbo].[ThayDoiTrongQuaTrinhHoc]
ADD CONSTRAINT [PK_ThayDoiTrongQuaTrinhHoc]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'ChinhSach'
ALTER TABLE [dbo].[ChinhSach]
ADD CONSTRAINT [PK_ChinhSach]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'VanBangDuocNhan'
ALTER TABLE [dbo].[VanBangDuocNhan]
ADD CONSTRAINT [PK_VanBangDuocNhan]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'LoaiVanBang'
ALTER TABLE [dbo].[LoaiVanBang]
ADD CONSTRAINT [PK_LoaiVanBang]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'HocBong'
ALTER TABLE [dbo].[HocBong]
ADD CONSTRAINT [PK_HocBong]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'CauLacBoThamGia'
ALTER TABLE [dbo].[CauLacBoThamGia]
ADD CONSTRAINT [PK_CauLacBoThamGia]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'CauLacBo'
ALTER TABLE [dbo].[CauLacBo]
ADD CONSTRAINT [PK_CauLacBo]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'SinhVien'
ALTER TABLE [dbo].[SinhVien]
ADD CONSTRAINT [PK_SinhVien]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'KhenThuongs'
ALTER TABLE [dbo].[KhenThuongs]
ADD CONSTRAINT [PK_KhenThuongs]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'KyLuats'
ALTER TABLE [dbo].[KyLuats]
ADD CONSTRAINT [PK_KyLuats]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'HoatDongDoanTheThamGias'
ALTER TABLE [dbo].[HoatDongDoanTheThamGias]
ADD CONSTRAINT [PK_HoatDongDoanTheThamGias]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [LoaiHoSoes_ID], [DonVis_ID] in table 'LoaiHoSoDonVi'
ALTER TABLE [dbo].[LoaiHoSoDonVi]
ADD CONSTRAINT [PK_LoaiHoSoDonVi]
    PRIMARY KEY NONCLUSTERED ([LoaiHoSoes_ID], [DonVis_ID] ASC);
GO

-- Creating primary key on [Quyens_ID], [DonVis_ID] in table 'QuyenDonVi'
ALTER TABLE [dbo].[QuyenDonVi]
ADD CONSTRAINT [PK_QuyenDonVi]
    PRIMARY KEY NONCLUSTERED ([Quyens_ID], [DonVis_ID] ASC);
GO

-- Creating primary key on [Users_ID], [DonVis_ID] in table 'UserDonVi'
ALTER TABLE [dbo].[UserDonVi]
ADD CONSTRAINT [PK_UserDonVi]
    PRIMARY KEY NONCLUSTERED ([Users_ID], [DonVis_ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [DonViID] in table 'Lop'
ALTER TABLE [dbo].[Lop]
ADD CONSTRAINT [FK_DonViLop]
    FOREIGN KEY ([DonViID])
    REFERENCES [dbo].[DonVi]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DonViLop'
CREATE INDEX [IX_FK_DonViLop]
ON [dbo].[Lop]
    ([DonViID]);
GO

-- Creating foreign key on [KhoaHocID] in table 'Lop'
ALTER TABLE [dbo].[Lop]
ADD CONSTRAINT [FK_KhoaHocLop]
    FOREIGN KEY ([KhoaHocID])
    REFERENCES [dbo].[KhoaHoc]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_KhoaHocLop'
CREATE INDEX [IX_FK_KhoaHocLop]
ON [dbo].[Lop]
    ([KhoaHocID]);
GO

-- Creating foreign key on [DonViID] in table 'PhienBanGiao'
ALTER TABLE [dbo].[PhienBanGiao]
ADD CONSTRAINT [FK_DonViPhienBanGiao]
    FOREIGN KEY ([DonViID])
    REFERENCES [dbo].[DonVi]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DonViPhienBanGiao'
CREATE INDEX [IX_FK_DonViPhienBanGiao]
ON [dbo].[PhienBanGiao]
    ([DonViID]);
GO

-- Creating foreign key on [LoaiHoSoID] in table 'HoSoDaNop'
ALTER TABLE [dbo].[HoSoDaNop]
ADD CONSTRAINT [FK_LoaiHoSoHoSoDaNop]
    FOREIGN KEY ([LoaiHoSoID])
    REFERENCES [dbo].[LoaiHoSo]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LoaiHoSoHoSoDaNop'
CREATE INDEX [IX_FK_LoaiHoSoHoSoDaNop]
ON [dbo].[HoSoDaNop]
    ([LoaiHoSoID]);
GO

-- Creating foreign key on [DanTocID] in table 'SinhVien'
ALTER TABLE [dbo].[SinhVien]
ADD CONSTRAINT [FK_SinhVienDanToc]
    FOREIGN KEY ([DanTocID])
    REFERENCES [dbo].[DanToc]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienDanToc'
CREATE INDEX [IX_FK_SinhVienDanToc]
ON [dbo].[SinhVien]
    ([DanTocID]);
GO

-- Creating foreign key on [TonGiaoID] in table 'SinhVien'
ALTER TABLE [dbo].[SinhVien]
ADD CONSTRAINT [FK_SinhVienTonGiao]
    FOREIGN KEY ([TonGiaoID])
    REFERENCES [dbo].[TonGiao]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienTonGiao'
CREATE INDEX [IX_FK_SinhVienTonGiao]
ON [dbo].[SinhVien]
    ([TonGiaoID]);
GO

-- Creating foreign key on [SinhVienID] in table 'ThamGiaOlympic'
ALTER TABLE [dbo].[ThamGiaOlympic]
ADD CONSTRAINT [FK_SinhVienThamGiaOlympic]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienThamGiaOlympic'
CREATE INDEX [IX_FK_SinhVienThamGiaOlympic]
ON [dbo].[ThamGiaOlympic]
    ([SinhVienID]);
GO

-- Creating foreign key on [SinhVienID] in table 'NghienCuuKhoaHoc'
ALTER TABLE [dbo].[NghienCuuKhoaHoc]
ADD CONSTRAINT [FK_SinhVienNghienCuuKhoaHoc]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienNghienCuuKhoaHoc'
CREATE INDEX [IX_FK_SinhVienNghienCuuKhoaHoc]
ON [dbo].[NghienCuuKhoaHoc]
    ([SinhVienID]);
GO

-- Creating foreign key on [SinhVienID] in table 'NhatKy'
ALTER TABLE [dbo].[NhatKy]
ADD CONSTRAINT [FK_SinhVienNhatKy]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienNhatKy'
CREATE INDEX [IX_FK_SinhVienNhatKy]
ON [dbo].[NhatKy]
    ([SinhVienID]);
GO

-- Creating foreign key on [LopID] in table 'SinhVien'
ALTER TABLE [dbo].[SinhVien]
ADD CONSTRAINT [FK_LopSinhVien]
    FOREIGN KEY ([LopID])
    REFERENCES [dbo].[Lop]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LopSinhVien'
CREATE INDEX [IX_FK_LopSinhVien]
ON [dbo].[SinhVien]
    ([LopID]);
GO

-- Creating foreign key on [SinhVienID] in table 'HoSoDaNop'
ALTER TABLE [dbo].[HoSoDaNop]
ADD CONSTRAINT [FK_SinhVienHoSoDaNop]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienHoSoDaNop'
CREATE INDEX [IX_FK_SinhVienHoSoDaNop]
ON [dbo].[HoSoDaNop]
    ([SinhVienID]);
GO

-- Creating foreign key on [SinhVienID] in table 'VanBangDuocNhan'
ALTER TABLE [dbo].[VanBangDuocNhan]
ADD CONSTRAINT [FK_SinhVienVanBangDuocNhan]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienVanBangDuocNhan'
CREATE INDEX [IX_FK_SinhVienVanBangDuocNhan]
ON [dbo].[VanBangDuocNhan]
    ([SinhVienID]);
GO

-- Creating foreign key on [LoaiVanBangID] in table 'VanBangDuocNhan'
ALTER TABLE [dbo].[VanBangDuocNhan]
ADD CONSTRAINT [FK_LoaiVanBangVanBangDuocNhan]
    FOREIGN KEY ([LoaiVanBangID])
    REFERENCES [dbo].[LoaiVanBang]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LoaiVanBangVanBangDuocNhan'
CREATE INDEX [IX_FK_LoaiVanBangVanBangDuocNhan]
ON [dbo].[VanBangDuocNhan]
    ([LoaiVanBangID]);
GO

-- Creating foreign key on [SinhVienID] in table 'HocBong'
ALTER TABLE [dbo].[HocBong]
ADD CONSTRAINT [FK_SinhVienHocBong]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienHocBong'
CREATE INDEX [IX_FK_SinhVienHocBong]
ON [dbo].[HocBong]
    ([SinhVienID]);
GO

-- Creating foreign key on [SinhVienID] in table 'CauLacBoThamGia'
ALTER TABLE [dbo].[CauLacBoThamGia]
ADD CONSTRAINT [FK_SinhVienCauLacBoThamGia]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienCauLacBoThamGia'
CREATE INDEX [IX_FK_SinhVienCauLacBoThamGia]
ON [dbo].[CauLacBoThamGia]
    ([SinhVienID]);
GO

-- Creating foreign key on [CauLacBoID] in table 'CauLacBoThamGia'
ALTER TABLE [dbo].[CauLacBoThamGia]
ADD CONSTRAINT [FK_CauLacBoCauLacBoThamGia]
    FOREIGN KEY ([CauLacBoID])
    REFERENCES [dbo].[CauLacBo]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CauLacBoCauLacBoThamGia'
CREATE INDEX [IX_FK_CauLacBoCauLacBoThamGia]
ON [dbo].[CauLacBoThamGia]
    ([CauLacBoID]);
GO

-- Creating foreign key on [SinhVienID] in table 'ThayDoiTrongQuaTrinhHoc'
ALTER TABLE [dbo].[ThayDoiTrongQuaTrinhHoc]
ADD CONSTRAINT [FK_SinhVienThayDoiTrongQuaTrinhHoc]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienThayDoiTrongQuaTrinhHoc'
CREATE INDEX [IX_FK_SinhVienThayDoiTrongQuaTrinhHoc]
ON [dbo].[ThayDoiTrongQuaTrinhHoc]
    ([SinhVienID]);
GO

-- Creating foreign key on [LoaiThayDoiID] in table 'ThayDoiTrongQuaTrinhHoc'
ALTER TABLE [dbo].[ThayDoiTrongQuaTrinhHoc]
ADD CONSTRAINT [FK_LoaiThayDoiThayDoiTrongQuaTrinhHoc]
    FOREIGN KEY ([LoaiThayDoiID])
    REFERENCES [dbo].[LoaiThayDoi]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LoaiThayDoiThayDoiTrongQuaTrinhHoc'
CREATE INDEX [IX_FK_LoaiThayDoiThayDoiTrongQuaTrinhHoc]
ON [dbo].[ThayDoiTrongQuaTrinhHoc]
    ([LoaiThayDoiID]);
GO

-- Creating foreign key on [LoaiHoSoes_ID] in table 'LoaiHoSoDonVi'
ALTER TABLE [dbo].[LoaiHoSoDonVi]
ADD CONSTRAINT [FK_LoaiHoSoDonVi_LoaiHoSo]
    FOREIGN KEY ([LoaiHoSoes_ID])
    REFERENCES [dbo].[LoaiHoSo]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [DonVis_ID] in table 'LoaiHoSoDonVi'
ALTER TABLE [dbo].[LoaiHoSoDonVi]
ADD CONSTRAINT [FK_LoaiHoSoDonVi_DonVi]
    FOREIGN KEY ([DonVis_ID])
    REFERENCES [dbo].[DonVi]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LoaiHoSoDonVi_DonVi'
CREATE INDEX [IX_FK_LoaiHoSoDonVi_DonVi]
ON [dbo].[LoaiHoSoDonVi]
    ([DonVis_ID]);
GO

-- Creating foreign key on [Quyens_ID] in table 'QuyenDonVi'
ALTER TABLE [dbo].[QuyenDonVi]
ADD CONSTRAINT [FK_QuyenDonVi_Quyen]
    FOREIGN KEY ([Quyens_ID])
    REFERENCES [dbo].[Quyen]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [DonVis_ID] in table 'QuyenDonVi'
ALTER TABLE [dbo].[QuyenDonVi]
ADD CONSTRAINT [FK_QuyenDonVi_DonVi]
    FOREIGN KEY ([DonVis_ID])
    REFERENCES [dbo].[DonVi]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_QuyenDonVi_DonVi'
CREATE INDEX [IX_FK_QuyenDonVi_DonVi]
ON [dbo].[QuyenDonVi]
    ([DonVis_ID]);
GO

-- Creating foreign key on [SinhVienID] in table 'KhenThuongs'
ALTER TABLE [dbo].[KhenThuongs]
ADD CONSTRAINT [FK_SinhVienKhenThuong]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienKhenThuong'
CREATE INDEX [IX_FK_SinhVienKhenThuong]
ON [dbo].[KhenThuongs]
    ([SinhVienID]);
GO

-- Creating foreign key on [SinhVienID] in table 'KyLuats'
ALTER TABLE [dbo].[KyLuats]
ADD CONSTRAINT [FK_SinhVienKyLuat]
    FOREIGN KEY ([SinhVienID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienKyLuat'
CREATE INDEX [IX_FK_SinhVienKyLuat]
ON [dbo].[KyLuats]
    ([SinhVienID]);
GO

-- Creating foreign key on [HoatDongDoanTheID] in table 'HoatDongDoanTheThamGias'
ALTER TABLE [dbo].[HoatDongDoanTheThamGias]
ADD CONSTRAINT [FK_HoatDongDoanTheHoatDongDoanTheThamGia]
    FOREIGN KEY ([HoatDongDoanTheID])
    REFERENCES [dbo].[HoatDongDoanThe]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HoatDongDoanTheHoatDongDoanTheThamGia'
CREATE INDEX [IX_FK_HoatDongDoanTheHoatDongDoanTheThamGia]
ON [dbo].[HoatDongDoanTheThamGias]
    ([HoatDongDoanTheID]);
GO

-- Creating foreign key on [SinhVien_ID] in table 'HoatDongDoanTheThamGias'
ALTER TABLE [dbo].[HoatDongDoanTheThamGias]
ADD CONSTRAINT [FK_HoatDongDoanTheThamGiaSinhVien]
    FOREIGN KEY ([SinhVien_ID])
    REFERENCES [dbo].[SinhVien]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HoatDongDoanTheThamGiaSinhVien'
CREATE INDEX [IX_FK_HoatDongDoanTheThamGiaSinhVien]
ON [dbo].[HoatDongDoanTheThamGias]
    ([SinhVien_ID]);
GO

-- Creating foreign key on [ChinhSachID] in table 'SinhVien'
ALTER TABLE [dbo].[SinhVien]
ADD CONSTRAINT [FK_SinhVienChinhSach]
    FOREIGN KEY ([ChinhSachID])
    REFERENCES [dbo].[ChinhSach]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinhVienChinhSach'
CREATE INDEX [IX_FK_SinhVienChinhSach]
ON [dbo].[SinhVien]
    ([ChinhSachID]);
GO

-- Creating foreign key on [Users_ID] in table 'UserDonVi'
ALTER TABLE [dbo].[UserDonVi]
ADD CONSTRAINT [FK_UserDonVi_User]
    FOREIGN KEY ([Users_ID])
    REFERENCES [dbo].[User]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [DonVis_ID] in table 'UserDonVi'
ALTER TABLE [dbo].[UserDonVi]
ADD CONSTRAINT [FK_UserDonVi_DonVi]
    FOREIGN KEY ([DonVis_ID])
    REFERENCES [dbo].[DonVi]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserDonVi_DonVi'
CREATE INDEX [IX_FK_UserDonVi_DonVi]
ON [dbo].[UserDonVi]
    ([DonVis_ID]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------